/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.foxline.clinicplus.manager;

import br.com.foxline.clinicplus.entity.Operator;
import br.com.foxline.clinicplus.service.OperatorService;
import br.com.foxline.clinicplus.util.Msg;
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

/**
 *
 * @author roniere
 */
@ManagedBean
@ViewScoped
public class ManagerOperator implements Serializable{
    @EJB
    OperatorService operatorService;
    
    private Operator operator;
    
    @PostConstruct
    public void init(){
        operator = new Operator();
    }

    public Operator getOperator() {
        return operator;
    }

    public void setOperator(Operator operator) {
        this.operator = operator;
    }
    
    public void create(){
        operatorService.save(operator);
        Msg.messagemInfo("Operador salvo com sucesso !!");
        operator = new Operator();
    }
    
    public List<Operator> autocomplete(String query){
        Operator operator = new Operator();
        operator.setName(query);
        return operatorService.findOperator(operator);
    }
}
